package com.personal.dao;

import com.personal.domain.Partner;
import com.personal.util.partDisplay.PartnerPart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @projectName: smartCommunity_springboot
 * @package: com.personal.dao
 * @className: PartnerDao
 * @author: bong~
 * @description: TODO
 * @date: 2023/8/9 10:02
 * @version: 1.0
 */

@Mapper
public interface PartnerDao {

    @Select("select * from partnerbusiness")
    List<Partner> selectAll();


    @Select("select id,customerName,customerCode,customerType,attributionRange,mainDockingMan,mainDockingManPhone from partnerbusiness")
    List<PartnerPart> selectPartAll();


    @Select("select id,customerName,customerCode,customerType,attributionRange,mainDockingMan,mainDockingManPhone from partnerbusiness " +
            "where customerName like CONCAT('%',#{name},'%') and customerCode like CONCAT('%',#{code},'%')")
    List<PartnerPart> selectPartByKey(String name,String code);


    @Insert("insert into partnerbusiness (id, affiliatedProject, customerName, customerAbbreviation," +
            "                                     customerType, customerCode, attributionRange, mainDockingMan," +
            "                                     mainDockingManPhone, documentType, documentCode, enterpriseUnifiedCreditCode," +
            "                                     legalRepresentative, legalRepresentativePhone, legalRepresentativeHousehold," +
            "                                     enterpriseTelephone, registrationStatus, establishmentDate, EnterpriseWebsite," +
            "                                     registeredCapital, paidCapital, enterpriseEmail, customerServiceManager," +
            "                                     customerServiceManagerPhone, emergencyContact, emergencyContactPhone," +
            "                                     financialCustomerCode, underRent, incubatedEnterprise, blacklist," +
            "                                     incubationAgreementDate, businessLicenseAddress, enterpriseAddress, product," +
            "                                     businessScope, remark, attachments) VALUE" +
            "                                    (null,#{affiliatedProject},#{customerName},#{customerAbbreviation}," +
            "                                    #{customerType},#{customerCode},#{attributionRange},#{mainDockingMan}," +
            "                                    #{mainDockingManPhone},#{documentType},#{customerCode},#{enterpriseUnifiedCreditCode}, " +
            "                                    #{legalRepresentative},#{legalRepresentativePhone},#{legalRepresentativeHousehold}," +
            "                                     #{enterpriseTelephone},#{registrationStatus},#{establishmentDate},#{EnterpriseWebsite}," +
            "                                     #{registeredCapital}, #{paidCapital}, #{enterpriseEmail}, #{customerServiceManager}," +
            "                                     #{customerServiceManagerPhone}, #{emergencyContact}, #{emergencyContactPhone}," +
            "                                     #{financialCustomerCode}, #{underRent}, #{incubatedEnterprise}, #{blacklist}," +
            "                                     #{incubationAgreementDate}, #{businessLicenseAddress}, #{enterpriseAddress}, #{product}," +
            "                                     #{businessScope}, #{remark}, #{attachments})")
    int add(Partner partner);

    @Select("select * from partnerbusiness where id=#{id}")
    Partner getUpdateData(int id);
    @Update("update partnerbusiness set affiliatedProject=#{affiliatedProject}, customerName=#{customerName}, customerAbbreviation=#{customerAbbreviation}," +
            "                                   customerType=#{customerType}, customerCode=#{customerCode}, attributionRange=#{attributionRange}, mainDockingMan=#{mainDockingMan}," +
            "                                   mainDockingManPhone=#{mainDockingManPhone}, documentType=#{documentType}, documentCode=#{documentCode}, enterpriseUnifiedCreditCode=#{enterpriseUnifiedCreditCode}," +
            "                                   legalRepresentative=#{legalRepresentative}, legalRepresentativePhone=#{legalRepresentativePhone}, legalRepresentativeHousehold=#{legalRepresentativeHousehold}," +
            "                                   enterpriseTelephone=#{enterpriseTelephone}, registrationStatus=#{registrationStatus}, establishmentDate=#{establishmentDate}, EnterpriseWebsite=#{EnterpriseWebsite}," +
            "                                   registeredCapital=#{registeredCapital}, paidCapital=#{paidCapital}, enterpriseEmail=#{enterpriseEmail}, customerServiceManager=#{customerServiceManager}," +
            "                                   customerServiceManagerPhone=#{customerServiceManagerPhone}, emergencyContact=#{emergencyContact}, emergencyContactPhone=#{emergencyContactPhone}," +
            "                                   financialCustomerCode=#{financialCustomerCode}, underRent=#{underRent}, incubatedEnterprise=#{incubatedEnterprise}, blacklist=#{blacklist}," +
            "                                   incubationAgreementDate=#{incubationAgreementDate}, businessLicenseAddress=#{businessLicenseAddress}, enterpriseAddress=#{enterpriseAddress}, product=#{product}," +
            "                                   businessScope=#{businessScope}, remark=#{remark}, attachments=#{attachments} where id=#{id}")
    int update(Partner partner);

    @Delete("delete from partnerbusiness where id=#{id}")
    int delete(int id);



}
